package DMSXL._2023Before.HashTable;

public class isHappy_ {
    public static void main(String[] args) {

    }
}

/*class Solution {
    public boolean isHappy(int n) {
        String s ;
        int result = n;
        int num;
        HashSet<Integer> integers = new HashSet<>();
        while(true){
            s = Integer.toString(result);
            result = 0;
            for (int i = 0; i < s.length(); i++) {
                num = Character.getNumericValue(s.charAt(i));
                result += num * num;
            }
            if(result == 1){
                return true;
            }
            if(integers.contains(result)){
                return false;
            }
            else {
                integers.add(result);
            }
        }
    }
}*/
/*class Solution {
    public boolean isHappy(int n) {
        String s ;

        int num;
        int fast = n;
        int slow = n;
        int result = 0;
        while(true){
            s = Integer.toString(fast);
            for (int i = 0; i < s.length(); i++) {
                num = Character.getNumericValue(s.charAt(i));
                result += num * num;
            }
            fast = result;
            result = 0;
            s = Integer.toString(fast);
            for (int i = 0; i < s.length(); i++) {
                num = Character.getNumericValue(s.charAt(i));
                result += num * num;
            }
            fast = result;
            result = 0;
            s = Integer.toString(slow);
            for (int i = 0; i < s.length(); i++) {
                num = Character.getNumericValue(s.charAt(i));
                result += num * num;
            }
            slow = result;
            result = 0;
            if(fast == slow){
                if(fast == 1)
                    return true;
                else
                    return false;
            }


        }
    }
}*/